﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class OutlookMaster : System.Web.UI.MasterPage
{

    public Label ContentHeader
    {
        get
        {
            return lblContent;
        }
        set
        {
            lblContent = value;
        }
    }

    public Label ActiveConnection
    {
        get
        {
            return lblActiveConnection;
        }
        set
        {
            lblActiveConnection = value;
        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session["user"] == null)
            {
                Session["ConnectionString"] = null;
                if (Request.AppRelativeCurrentExecutionFilePath != "~/Default.aspx")
                {
                    Response.Redirect("~/Default.aspx");
                }
            }
            if (Session["ConnectionString"] == null)
            {
                panDBobjects.Visible = false;
                if (Request.AppRelativeCurrentExecutionFilePath != "~/Pages/ConnectionList.aspx" &&
                    Request.AppRelativeCurrentExecutionFilePath != "~/Pages/Connection.aspx" &&
                    Request.AppRelativeCurrentExecutionFilePath != "~/Default.aspx")
                {
                    Response.Redirect("~/Pages/ConnectionList.aspx");
                }
            }
            else
            {
                lblActiveConnection.Text = string.Format("Active connection: {0}", Session["ConnectionName"]);
            }
        }
    }
}
